package code.D1212;

/**
 * author : yeswater
 * date : 2023/12/12
 * 
 * 颜色分类
 * 
 * 相同颜色的元素相邻
 * 红白蓝 -> 0 1 2
 * 
 * 04 21 -> 
 */

public class T075 {
    public static void main(String[] args) {
        int[] nums = {2,0,2,1,1,0};
        sortColors(nums);
    }
    public static void sortColors(int[] nums) {
        int red = 0, white = 0, blue = 0;
        for (int num : nums) {
            if (num == 0) red++;
            if (num == 1) white++;
            if (num == 2) blue++;
        }
        for (int i = 0; i < red; i++) {
            nums[i] = 0;
        }
        for (int i = red; i < red + white; i++) {
            nums[i] = 1;
        }
        for (int i = red + white; i < red+white+blue; i++) {
            nums[i] = 2;
        }
    }
}
